package cn.zhqr.common.util.tree;


import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 树状结构节点
 * Created by yantingjun on 2016/11/1.
 */
public class TreeNode implements INode{
    private int id;
    private int pid;
    private String name;
    private String logo;
    private int level;
    private Map data;  //每个节点可以携带参数
    private List<TreeNode> subNodes = new ArrayList<TreeNode>();

    public Integer getId() {
        return id;
    }


    public void setId(int id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getLogo() {
        return logo;
    }

    public void setLogo(String logo) {
        this.logo = logo;
    }

    public Integer getLevel() {
        return level;
    }

    public void setLevel(int level) {
        this.level = level;
    }

    public List<TreeNode> getSubNodes() {
        return subNodes;
    }

    public void setSubNodes(List subNodes) {
        this.subNodes = subNodes;
    }

    public void addSubNode(TreeNode subNode){
        subNodes.add(subNode);
    }

    public Integer getPid() {
        return pid;
    }

    public void setPid(int pid) {
        this.pid = pid;
    }

    public Map getData() {
        return data;
    }

    public void setData(Map data) {
        this.data = data;
    }

    public void putData(Object key,Object value){
        if(data==null){
            data = new HashMap<>();
        }
        data.put(key,value);
    }
}
